<?php
if ( $po_list['is_print'] ) {
	header('Content-type: application/vnd.ms-excel');
	header('Content-Disposition: attachment; filename=PO List ' . $po_list['cur_date'] .'.xls');
}
?>
<table border=1 style="{{ $text_calibri }} {{ $text_size_14 }} {{ $margin_10 }}">
<!-- Headers -->
<tr style="{{ $black_and_white }}">
	<th>{{ $print_po_number }}</th>
	<th>{{ $print_po_status }}</th>
	<th>{{ $print_po_date }}</th>
	<th>{{ $print_po_delivery_date }}</th>
	<th>{{ strtoupper($print_prepared_by) }}</th>
	<th>{{ $print_company_code }}</th>
	<th>{{ $print_vendor_code }}</th>
	<th>{{ $print_vendor }}</th>
	<th>{{ $print_item_id }}</th>
	<th>{{ $print_order_id }}</th>
	<th>{{ $print_item_status }}</th>
	<th>{{ $print_product_id }}</th>
	<th>{{ $print_product_model }}</th>
	<th>{{ $print_product_name }}</th>
	<th>{{ $print_product_options }}</th>
	<th>{{ $print_product_srp }}</th>
	<th>{{ $print_qty }}</th>
	<th>{{ $print_remarks }}</th>
</tr>

<!-- PO Item Rows -->
@foreach ( $po_list['items'] AS $po_item )
<tr>
	<td style="{{ $text_top }} {{ $text_left }}">{{ strtoupper($po_item->vendor_code) }}-{{ str_pad($po_item->po_id, 3, '0', STR_PAD_LEFT) }}-{{ date_format($po_item->created_at, 'Ymd') }}</td>
	<td style="{{ $text_top }} {{ $text_left }}">{{ $po_list['statuses'][$po_item->po_status] }}</td>
	<td style="{{ $text_top }}">@if ( $po_item->po_status == Constant::PO_APPROVED ) {{ Formatter::toDateFormat( $po_item->approved_at, 'm/d/Y' ) }} @else N/A @endif</td>
	<td style="{{ $text_top }}">@if ( $po_item->po_status == Constant::PO_APPROVED ) {{ Formatter::toDateFormat( $po_item->approved_at, 'm/d/Y', 7 ) }} @else N/A @endif</td>
	<td style="{{ $text_top }}">{{ $po_item->firstname }} {{ $po_item->lastname }}</td>
	<td style="{{ $text_top }}">{{ strtoupper($po_item->company_code) }}</td>
	<td style="{{ $text_top }}">{{ strtoupper($po_item->vendor_code) }}</td>
	<td style="{{ $text_top }}">{{ $po_item->vendor_name }}</td>
	<td style="{{ $text_top }} {{ $text_left }}">{{ $po_item->item_id }}</td>
	<td style="{{ $text_top }} {{ $text_left }}">{{ $po_item->ORDER_id }}</td>
	<td style="{{ $text_top }} {{ $text_left }}">{{ $po_list['order_statuses'][$po_item->item_status] }}</td>
	<td style="{{ $text_top }} {{ $text_left }}">{{ $po_item->PRODUCT_id }}</td>
	<td style="{{ $text_top }} {{ $text_left }}">{{ $po_item->prod_model }}</td>
	<td style="{{ $text_top }} {{ $text_left }}">
		{{ $po_item->prod_name }}
	</td>
	<td style="{{ $text_top }}">
		@if ( array_key_exists($po_item->ORDER_id . '_' . $po_item->PRODUCT_id, $po_list['options']) )
			@foreach ($po_list['options'][$po_item->ORDER_id . '_' . $po_item->PRODUCT_id] as $key => $option)
				@if ( $key != 0 ) <br/> @endif
				{{ $option['option_value'] }} (+{{ $option['price'] }}) - {{ $option['quantity'] }}
			@endforeach
		@else
			N/A
		@endif
	</td>
	<td style="{{ $text_top }} {{ $text_right }}">{{ number_format($po_item->prod_srp, 2) }}</td>
	<td style="{{ $text_top }} {{ $text_right }}">{{ $po_item->quantity }}</td>
	<td style="{{ $text_top }} {{ $text_left }}">{{ $po_item->po_comment }}</td>
</tr>
@endforeach
</table>